//
//  StudentReviewsViewController.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/26.
//

#import "StudentReviewsViewController.h"
#import "StudentReviewsCell.h"
#import "StudentReviewsModel.h"
#import "StarView.h"
@interface StudentReviewsViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UILabel *scoreLabel;
@property (nonatomic,strong) UILabel *peopleNumberLabel;
@property (nonatomic, strong) StarView *jxzlStarView;
@property (nonatomic, strong) StarView *fwtdStarView;
@property (nonatomic, strong) StarView *cdssStarView;
@end

@implementation StudentReviewsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navgationheadv.titlelabel.text = @"学员点评";
    self.offset = 1;
}

- (void)setupUI {
    [super setupUI];

    self.refreshState = JKRefreshStateLoading;
    self.tableView.frame = CGRectMake(0, SafeAreaTopHight, APPwidth, APPheight-SafeAreaTopHight);
    
    UIView *HeaderV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 165)];
    HeaderV.backgroundColor = [UIColor whiteColor];
    
    UIView *bjview = [[UIView alloc]initWithFrame:CGRectMake(16, 20, 85, 80)];
    bjview.backgroundColor = rgba(206, 226, 255, 1);
    bjview.layer.cornerRadius = 6;
    bjview.layer.masksToBounds = YES;
    [HeaderV addSubview:bjview];
    
    self.scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 10, 75, 40)];
    self.scoreLabel.textColor = rgba(22, 120, 255, 1);
    self.scoreLabel.font = kPingFangRegular(34);
    self.scoreLabel.textAlignment = NSTextAlignmentCenter;
    self.scoreLabel.text = @"4.3";
    [bjview addSubview:self.scoreLabel];
    
    self.peopleNumberLabel  = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 75, 15)];
    self.peopleNumberLabel.textColor = rgba(153, 153, 153, 1);
    self.peopleNumberLabel.font = kPingFangRegular(10);
    self.peopleNumberLabel.textAlignment = NSTextAlignmentCenter;
    self.peopleNumberLabel.text = @"102人评价";
    [bjview addSubview:self.peopleNumberLabel];
    
    UILabel *jxzltitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(110, 20, 60, 22)];
    jxzltitleLabel.textColor = rgba(51, 51, 51, 1);
    jxzltitleLabel.font = kPingFangRegular(14);
    jxzltitleLabel.textAlignment = NSTextAlignmentCenter;
    jxzltitleLabel.text = @"教学质量";
    [HeaderV addSubview:jxzltitleLabel];
    
    UILabel *fwtdtitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(110, 49, 60, 22)];
    fwtdtitleLabel.textColor = rgba(51, 51, 51, 1);
    fwtdtitleLabel.font = kPingFangRegular(14);
    fwtdtitleLabel.textAlignment = NSTextAlignmentCenter;
    fwtdtitleLabel.text = @"服务态度";
    [HeaderV addSubview:fwtdtitleLabel];
    
    UILabel *cdsstitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(110, 78, 60, 22)];
    cdsstitleLabel.textColor = rgba(51, 51, 51, 1);
    cdsstitleLabel.font = kPingFangRegular(14);
    cdsstitleLabel.textAlignment = NSTextAlignmentCenter;
    cdsstitleLabel.text = @"场地设施";
    [HeaderV addSubview:cdsstitleLabel];
    
    
    self.jxzlStarView = [[StarView alloc] initWithFrame:CGRectMake(180, 20, APPwidth-200, 22) EmptyImage:@"emptyStar" StarImage:@"Star"];
    self.jxzlStarView.starNumber = 2;
    self.jxzlStarView.ischoose = NO;
    [HeaderV addSubview:self.jxzlStarView];
    
    self.fwtdStarView = [[StarView alloc] initWithFrame:CGRectMake(180, 49, APPwidth-200, 22) EmptyImage:@"emptyStar" StarImage:@"Star"];
    self.fwtdStarView.starNumber = 4;
    self.fwtdStarView.ischoose = NO;
    [HeaderV addSubview:self.fwtdStarView];
    
    self.cdssStarView = [[StarView alloc] initWithFrame:CGRectMake(180, 78, APPwidth-200, 22) EmptyImage:@"emptyStar" StarImage:@"Star"];
    self.cdssStarView.starNumber = 1;
    self.cdssStarView.ischoose = NO;
    [HeaderV addSubview:self.cdssStarView];
    
    UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 115, APPwidth, 10)];
    lineview.backgroundColor = rgba(245, 245, 250, 1);
    [HeaderV addSubview:lineview];
    
    UIView *myDataLineV = [[UIView alloc]initWithFrame:CGRectMake(15, 140, 3, 15)];
    myDataLineV.backgroundColor = rgba(22, 120, 255, 1);
    myDataLineV.layer.cornerRadius = 2;
    [HeaderV addSubview:myDataLineV];
    UILabel *myDataLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(myDataLineV.frame)+5, 140, 150, 15)];
    myDataLab.text = @"精选好评";
    myDataLab.textColor = [UIColor blackColor];
    myDataLab.textAlignment = 0;
    myDataLab.font = kPingFangSemibold(16);
    [HeaderV addSubview:myDataLab];
    
    self.tableView.tableHeaderView = HeaderV;
    
}


- (void)getData
{
    for (NSInteger i=0; i<(self.offset)*WKLLimit; i++) {
        
        StudentReviewsModel *model = [[StudentReviewsModel alloc]init];
        model.ReviewsID = [NSString stringWithFormat:@"%ld",i];
        model.ReviewsUserName = [NSString stringWithFormat:@"刘海燕%ld",i];
        model.ReviewsUserAvatar = [NSString stringWithFormat:@"湖南省长沙县安沙镇毛塘工业园%ld",i];
        model.ReviewsTime = [NSString stringWithFormat:@"08-20 21:36"];
        model.ReviewsContent = [NSString stringWithFormat:@"很好，教练态度非常认真，每次考试都是一次就过，驾照很轻松就拿到了！"];
        if (i==1) {
            model.ReviewsContent = [NSString stringWithFormat:@"本来一直卡在侧方位停车这个地方，教练一直非常耐心的教我找到原因，感谢！本来一直卡在侧方位停车这个地方，教练一直非常耐心的教我找到原因，感谢！本来一直卡在侧方位停车这个地方，教练一直非常耐心的教我找到原因，感谢！"];
        }
        [self.dataArray addObject:model];
    }
    self.refreshState = JKRefreshStateFinish;
    [self.tableView reloadData];
}


#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    StudentReviewsModel *model = self.dataArray[indexPath.row];
    
    CGFloat contentLabelh = [LongHelper textHeight:model.ReviewsContent WithUIFont:kPingFangRegular(14) AndWidth:APPwidth-32];
    if (contentLabelh < 20) {
        contentLabelh = 20;
    }
    return contentLabelh+85;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    StudentReviewsCell *cell=[tableView dequeueReusableCellWithIdentifier:@"StudentReviewsCell"];
    if (!cell) {
        cell=[[StudentReviewsCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"StudentReviewsCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell cellFillWithModel:self.dataArray[indexPath.row]];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

@end
